package android.bignerdranch.shiyan3;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    TextView tv1,tv2;
    Button btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        tv1 = (TextView)findViewById(R.id.stv1);
        tv2 = (TextView)findViewById(R.id.stv2);
        btn1 = (Button)findViewById(R.id.btn1);
        btn2 = (Button)findViewById(R.id.btn2);
        btn3 = (Button)findViewById(R.id.btn3);
        btn4 = (Button)findViewById(R.id.btn4);
        btn5 = (Button)findViewById(R.id.btn5);
        btn6 = (Button)findViewById(R.id.btn6);
        btn7 = (Button)findViewById(R.id.btn7);
        btn8 = (Button)findViewById(R.id.btn8);

        btn1.setOnClickListener(this);
        btn2.setOnClickListener(new MyClickListener());

        btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                tv2.setText(R.string.tv2_3);
            }
        });

        btn4.setOnClickListener(view -> tv2.setText(R.string.tv2_4));
        btn5.setOnClickListener(new MyOnClickListener() {
            public void onClick(View view){
                super.onClick(view);
                tv2.setText(R.string.tv2_5);
            }
        });

        btn7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(MainActivity.this,Showmessage.class);
                startActivity(intent);
            }
        });

        btn8.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setClass(MainActivity.this,ProgressDialogTest.class);
                startActivity(intent);
            }
        });
    }

    public void onClick(View v)
    {
        tv2.setText(R.string.tv2_1);
    }

    class MyClickListener implements View.OnClickListener{
        @Override
        public void onClick(View v){
            tv2.setText(R.string.tv2_2);
        }
    }

    public void onClick6(View v)
    {
        tv2.setText(R.string.tv2_6);
    }


    class MyOnClickListener implements View.OnClickListener{

        @Override
        public void onClick(View view) {

        }
    }

}